home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / menu_dvd.swf / scripts / __Packages / HtmlListboxCellRenderer.as < prev    next >
Text File  |  2007-11-07  |  3KB  |  89 lines

  1. class HtmlListboxCellRenderer extends mx.core.UIComponent
  2. {
  3.    static var style_sheet = null;
  4.    static var USE_EMBEDDED_FONT = true;
  5.    var previousLabel = null;
  6.    function HtmlListboxCellRenderer()
  7.    {
  8.       super();
  9.    }
  10.    function createChildren(Void)
  11.    {
  12.       if(HtmlListboxCellRenderer.CssUrl != undefined && HtmlListboxCellRenderer.style_sheet == null)
  13.       {
  14.          HtmlListboxCellRenderer.style_sheet = new TextField.StyleSheet();
  15.          HtmlListboxCellRenderer.style_sheet.load(HtmlListboxCellRenderer.CssUrl);
  16.       }
  17.       if(this.htmlComponent == undefined)
  18.       {
  19.          this.createLabel("htmlComponent",1);
  20.       }
  21.       this.htmlComponent.html = true;
  22.       this.htmlComponent.embedFonts = HtmlListboxCellRenderer.USE_EMBEDDED_FONT;
  23.       this.htmlComponent.border = false;
  24.       this.htmlComponent.multiline = true;
  25.       this.htmlComponent.wordWrap = true;
  26.       this.htmlComponent.selectable = false;
  27.       this.htmlComponent.background = false;
  28.       this.htmlComponent.styleSheet = HtmlListboxCellRenderer.style_sheet;
  29.       this.size();
  30.    }
  31.    function size(Void)
  32.    {
  33.       this.htmlComponent.setSize(this.__width - 2,this.__height);
  34.    }
  35.    function setValue(str, item, sel)
  36.    {
  37.       if(item == undefined)
  38.       {
  39.          this.htmlComponent.htmlText = str;
  40.          this.previousLabel = null;
  41.          return undefined;
  42.       }
  43.       var columnIndex = this.columnIndex;
  44.       var columnName = this.getDataLabel();
  45.       var htmlTxt = str;
  46.       var labelSupSub = this.HtmlFunction(item.label);
  47.       if(item.icon == "L")
  48.       {
  49.          htmlTxt = "<span class=\'rowText\'>" + labelSupSub + "</span>";
  50.       }
  51.       else if(item.icon == "R")
  52.       {
  53.          htmlTxt = "<span class=\'rowText\'><i>" + labelSupSub + "</i></span>";
  54.       }
  55.       else if(item.icon == "S")
  56.       {
  57.          htmlTxt = "<span class=\'rowText\'>" + labelSupSub + "</span>";
  58.       }
  59.       else
  60.       {
  61.          htmlTxt = "<span class=\'rowText\'>" + labelSupSub + "</span>";
  62.       }
  63.       this.htmlComponent.htmlText = htmlTxt;
  64.    }
  65.    function getPreferredHeight(Void)
  66.    {
  67.       if(this.owner == undefined)
  68.       {
  69.          return 18;
  70.       }
  71.       return this.owner.__height;
  72.    }
  73.    function HtmlFunction(inLabel)
  74.    {
  75.       if(inLabel.indexOf("<sup>") >= 0 || inLabel.indexOf("<sub>") >= 0)
  76.       {
  77.          return StringUtils.subSupFromHTML(inLabel);
  78.       }
  79.       return inLabel;
  80.    }
  81.    function setColor(col)
  82.    {
  83.       if(this.htmlComponent != undefined)
  84.       {
  85.          this.htmlComponent.textColor = col;
  86.       }
  87.    }
  88. }
  89.